package com.ithei.edu.info.manager.controller;

import com.ithei.edu.info.manager.service.StudentService;
import com.ithei.edu.info.manager.service.impl.StudentServiceImpl;

import java.io.IOException;
import java.util.Scanner;

public class StudentController {
    private StudentService studentService = new StudentServiceImpl();

    private Scanner sc = new Scanner(System.in);

    // 开启学生管理系统, 并展示学生管理系统菜单
    public void start() throws IOException {
        studentLoop:
        while (true) {
            System.out.println("--------欢迎来到 <学生> 管理系统--------");
            System.out.println("请输入您的选择: 1.添加学生  2.删除学生  3.修改学生  4.查看学生  5.退出");
            String choice = sc.next();
            switch (choice) {
                case "1":
                    // System.out.println("添加");
                    studentService.addStudent();
                    break;
                case "2":
                    // System.out.println("删除");
                    studentService.deleteStudentById();
                    break;
                case "3":
                    // System.out.println("修改");
                    studentService.setStudentById();
                    break;
                case "4":
                    // System.out.println("查询");
                    studentService.selectAll();
                    break;
                case "5":
                    System.out.println("感谢您使用学生管理系统, 再见!");
                    break studentLoop;
                default:
                    System.out.println("您的输入有误, 请重新输入");
                    break;
            }
        }
    }
}
